package top.jle.wx.proxy.api.redPacket;

import com.alibaba.fastjson2.JSONObject;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import top.jle.wx.proxy.api.ResponseBack;
import top.jle.wx.proxy.domain.redpack.GetRedPackInfoDTO;
import top.jle.wx.proxy.domain.redpack.GetTransferInfoDTO;
import top.jle.wx.proxy.domain.redpack.SendRedPackDTO;
import top.jle.wx.proxy.domain.redpack.TransferDTO;
import top.jle.wx.proxy.facade.RedPacketFacade;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/redPacket")
@Tag(name= "红包API")
public class RedPacketAPI {
    @Autowired
    private RedPacketFacade redPacketFacade;

    @Operation(summary="发送现金红包")
    @PostMapping("/sendRedPacket")
    public ResponseBack<JSONObject> sendRedPacket(@RequestBody SendRedPackDTO dto) throws Exception {
        return ResponseBack.success(redPacketFacade.sendRedPacket(dto));
    }
    @Operation(summary="获取红包记录信息")
    @PostMapping("/getRedPacketInfo")
    public ResponseBack<JSONObject> getRedPacket(@RequestBody GetRedPackInfoDTO dto) throws Exception {
        return ResponseBack.success(redPacketFacade.getRedPacketInfo(dto));
    }

    @Operation(summary="发起现金支付（直接支付到零钱）")
    @PostMapping("/sendTransfer")
    public ResponseBack<JSONObject> sendTransfer(@RequestBody TransferDTO dto) throws Exception {
        return ResponseBack.success(redPacketFacade.sendTransfer(dto));
    }
    @Operation(summary="获取现金支付信息")
    @PostMapping("/getTransferInfo")
    public ResponseBack<JSONObject> getTransfer(@RequestBody GetTransferInfoDTO dto) throws Exception {
        return ResponseBack.success(redPacketFacade.getTransferInfo(dto));
    }
}
